var ngTip = new function () {
    this.close = function () {
        $ ('.alert').fadeOut ('fast')
        setTimeout (function () {
            $ ('.alert').remove ()
        }, 200)
    }
    this.tip = function ( message, type ) {
        var html = '<div class="alert ngTip"><button type="button" class="close" onclick="ngTip.close()">X</button><div class="alert-content"><i></i><p class="content"></p></div></div>'
        var jq = $ (html)
        jq.find ('.content').html (message.replace ('\r\n', '<br/>'))
        jq.appendTo ('body').fadeIn ('fast')
        if (message.length * 20 > 800) {
            $ ('.ngTip').width ('800').css ('margin-left', -message.length * 1.5)
        }
        $ ('.alert').addClass (function ( csstype ) {
            csstype = type || 'success'
            return 'alert-' + csstype
        })
        setTimeout (function () {
            ngTip.close ()
        }, 3000)
    }
}
